package com.situ.study.day4;

import org.junit.Test;

import java.util.Scanner;

public class SwitchDemo {
//   >=90   <=100   优秀
//   >=80    <90       良好
//   >=70    <80       一般
//   >=60    <70      及格
//   <60                   不及格
    @Test
    public void test1() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩：");
        int score = scanner.nextInt();
        //非法输入或者条件提前拦截，卫操作
        if (score < 0 || score > 100) {
            System.out.println("输入成绩非法");
            return;
        }

        switch (score / 10) {
            case 10:
                System.out.println("优秀");
            case 9:
                System.out.println("优秀");
                break;
            case 8:
                System.out.println("良好");
                break;
            case 7:
                System.out.println("一般");
                break;
            case 6:
                System.out.println("及格");
                break;
            default:
                System.out.println("不及格");
                break;
        }
    }

    /*练习：
    输入月份、年份判断天数：
    1、3、5、7、8、10、12  -------- 31天
    4、6 、9、11--------------------30天
    2----------------------------------28/29天*/
    @Test
    public void test55() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("30天");
                break;
            case 2:
                System.out.println("请输入年份");
                int year = scanner.nextInt();
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                    System.out.println(year + "是闰年 29天");
                } else {
                    System.out.println(year + "不是闰年 28天");
                }
                break;
        }
    }


}
